package org.example.coursemangementserver.server.handler;

import org.example.coursemangementserver.server.mapper.EnrollmentMapper;
import org.example.coursemangementserver.server.mapper.SelectionInformationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class EnrollmentStatusScheduler {

    @Autowired
    private EnrollmentMapper enrollmentMapper;

    @Scheduled(cron = "0 0 1 * * ?")
    public void updateEnrollmentStatus() {
        enrollmentMapper.updateStatusToFinished();
    }

    @Autowired
    private SelectionInformationMapper selectionInformationMapper;

    // 每天凌晨1点执行一次
    @Scheduled(cron = "0 0 1 * * ?")
    public void updateSelectionStatus() {
        selectionInformationMapper.updateSelectionStatusToEnded();
    }
}
